﻿// ------------------------------------------------------------------------------
// <copyright file="GlobalNavigationMenuItem.cs" company="skumaronline.com">
//    Copyright (C) 2012 Suresh Kumar T.
//
//    This program is free software; you can redistribute it and/or
//    modify it under the terms of the GNU General Public License
//    as published by the Free Software Foundation version 2
//    of the License.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    http://www.gnu.org/licenses/gpl-2.0.html
//
// </copyright>
// ------------------------------------------------------------------------------

namespace StoreAppLib.Controls
{
    using System;
    using Windows.UI.Xaml;

    /// <summary>
    /// Menu item that support global navigation
    /// </summary>
    public sealed class GlobalNavigationMenuItem : MenuItem
    {
        /// <summary>
        /// Navigating To Page type property
        /// </summary>
        public static readonly DependencyProperty PageProperty =
            DependencyProperty.Register("Page", typeof(Type), typeof(GlobalNavigationMenuItem), new PropertyMetadata(null));

        /// <summary>
        /// Initializes a new instance of the <see cref="GlobalNavigationMenuItem" /> class
        /// </summary>
        public GlobalNavigationMenuItem()
            : base()
        {
            this.DefaultStyleKey = typeof(GlobalNavigationMenuItem);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GlobalNavigationMenuItem" /> class
        /// </summary>
        /// <param name="id">Menu Id object</param>
        /// <param name="label">Menu label</param>
        /// <param name="page">Type of navigating to page</param>
        public GlobalNavigationMenuItem(object id, string label, Type page)
            : this()
        {
            this.Id = id;
            this.Label = label;
            this.Page = page;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GlobalNavigationMenuItem" /> class.
        /// </summary>
        /// <param name="menuItem">The menu item defined in the container page</param>
        internal GlobalNavigationMenuItem(IMenuItem menuItem)
            : base(menuItem)
        {
        }

        /// <summary>
        /// Gets or sets Navigating To Page type
        /// </summary>
        public Type Page
        {
            get
            {
                return (Type)this.GetValue(PageProperty);
            }

            set
            {
                this.SetValue(PageProperty, value);
            }
        }
    }
}
